using System.Collections;
using System.Xml.Serialization;

namespace App.Modelo.Menu
{
    public class MenuBoton : MenuBaseItem
    {
        private ArrayList items;


        public MenuBoton()
        {

            items = new ArrayList();
        }
        public MenuBoton(string Text)
            : this()
        {
            this.Text = Text;
        }
        public  MenuBoton(string Text, string ImageKey)
            : this()
        {
            this.Text = Text;
            this.Image = ImageKey;
        }

        public MenuBoton(string Text, string ImageKey, string Command)
            : this(Text, ImageKey)
        {
            this.Command = Command;
        }

        public MenuBoton(string Text, string ImageKey, string Command, bool useRole)
            : this(Text, ImageKey, Command)
        {
            this.ComprobarPermiso = useRole;
        }

        public MenuBoton(MenuBaseItem[] Items)
            : this()
        {
            this.Items = Items;
        }
        public MenuBoton(string Text, string ImageKey, MenuBaseItem[] Items)
            : this(Text, ImageKey)
        {
            this.Items = Items;
        }

        public void AddItem(MenuBaseItem item)
        {
            items.Add(item);
        }

        [XmlElement("item", typeof(MenuBoton))]
        [XmlElement("separator", Type = typeof(MenuItemSeparator))]
        public MenuBaseItem[] Items
        {
            get
            {
                MenuBaseItem[] _items = new MenuBaseItem[items.Count];
                items.CopyTo(_items);
                return _items;
            }
            set
            {
                if (value == null) return;
                MenuBaseItem[] _items = (MenuBaseItem[])value;
                items.Clear();
                foreach (MenuBaseItem item in _items)
                    items.Add(item);
            }
        }

    }
}